import QtQuick 2.12
import QtQuick.Controls 2.12
import ".."

SpinBox {
    id: control
    property int multiple: 1
    textFromValue: function(value) {
        return value / multiple;
    }
    contentItem: TextEdit {
        text: control.textFromValue(control.value, control.locale)
        font: control.font
        color: Common.colorText
        horizontalAlignment: Qt.AlignHCenter
        verticalAlignment: Qt.AlignVCenter
        onTextChanged: {
            control.value = Number(text) * multiple
        }
    }
    up.indicator: Item {
        x: parent.width - width
        height: parent.height
        width: height
        Image {
            //source: "qrc:/Images/param_inc.png"
            anchors.centerIn: parent
            scale: control.up.pressed ? 0.95 : 1
        }
        Rectangle {
            height: parent.height
            width: 1
            color: Common.colorMain
            anchors.left: parent.left
        }
    }

    down.indicator: Item {
        x: 0
        height: parent.height
        width: height
        Image {
            //source: "qrc:/Images/param_dec.png"
            anchors.centerIn: parent
            scale: control.down.pressed ? 0.95 : 1
        }
        Rectangle {
            height: parent.height
            width: 1
            color: Common.colorMain
            anchors.right: parent.right
        }
    }

    background: Rectangle {
        width: parent.width
        border.color: Common.colorMain
        border.width: 1
        radius: 5
    }
}
